package cn.yunhe.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity(name = "课程")
@Table(name = ("course1"))
public class Course implements Serializable {
    private int id;
    private String name;
    private Set<Student> studentSet=new HashSet<>();

    public Course() {
    }

    public Course(String name) {
        this.name = name;
    }

    public Course(int id, String name, Set<Student> studentSet) {
        this.id = id;
        this.name = name;
        this.studentSet = studentSet;
    }

    @Id
    @GeneratedValue
    @Column(name = ("id"))
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = ("name"))
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = ("courseSet"))
    public Set<Student> getStudentSet() {
        return studentSet;
    }

    public void setStudentSet(Set<Student> studentSet) {
        this.studentSet = studentSet;
    }
}
